package com.hfut.manage.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hfut.manage.pojo.JobPosition;
import com.hfut.manage.pojo.Result;
import com.hfut.manage.pojo.Teacher;
import com.hfut.manage.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/analytics")
public class ReportController {
    @Autowired
    private ITeacherService teacherService;

    @GetMapping
    public Result list() {
        List<Map<String, Object>> titleResult = teacherService.listMaps(
                new QueryWrapper<Teacher>()
                        .select("department AS  department_name,title AS title_name, COUNT(*) AS employee_count")
                        .groupBy("department", "title")
        );
        return Result.success(titleResult);
    }

}
